part of leancloud_rest_api;

/// Configures the logger.
class LraLogger {
  static const int offLevel = 0;

  static const int errorLevel = 1;

  static const int warningLevel = 2;

  static const int debugLevel = 3;

  static int level = offLevel;

  static void setLevel(int logLevel, LraRestApi api) {
    level = logLevel;
    if (level >= debugLevel) {
      api._httpClient.enableLog();
    }
  }

  /// Prints an error message.
  static void error(dynamic message) {
    if (level < errorLevel) {
      return;
    }
    print('[ERROR]: $message');
  }

  /// Prints a warning message.
  static void warning(dynamic message) {
    if (level < warningLevel) {
      return;
    }
    print('[WARN]: $message');
  }

  /// Prints a debug message.
  static void debug(dynamic message) {
    if (level < debugLevel) {
      return;
    }
    print('[DEBUG]: $message');
  }
}
